<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>

<%@ page import="com.msmall.base.util.ConstantDB" language="java"%>
<%@ page import="com.msmall.community.space.util.SpaceConstants" language="java"%>
<c:set var="UNLOCK_STATUS" value="<%=ConstantDB.UNLOCK_STATUS%>"></c:set>
<c:set var="LOCK_STATUS" value="<%=ConstantDB.LOCK_STATUS%>"></c:set>
<c:set var="SPACE_WIDGET_PART_ALBUM" value="<%=SpaceConstants.SPACE_WIDGET_PART_ALBUM%>"></c:set>

<div class="spaw730nav">
	<p class="sHB00 fl" onclick="spaceIndexNav(<c:out value='${SPACE_WIDGET_PART_ALBUM}'/>)">
		我的相册
	</p>
	<p class="fr" style="margin-top:-5px;margin-right:400px">
		<a style="float:left;" class="but82" id="a_space_album_updload" href="javascript:spaceAlbumUpload()">上传照片</a>
		<a style="float:left;margin-left:15px;" class="but82" id="a_space_album" href="javascript:createAlbum()">创建相册</a>
	</p>
</div>
<div class="spalistphoto">
	<form id="f_new_album" action="<c:url value='/album/save.do'/>" method="POST" >
		<input id="album_id" name="album.albumid" value="${album.albumid}" type="hidden"/>
		
		相册名:
		<input id="album_title" name="album.title" value="${album.title}" size="10" class="input"/>
		<br/>
		是否需要密码：
		<input id="album_lockstatus" name="album.lockStatus" value="${LOCK_STATUS}" onclick="javascript:albumLockStatus(this)" type="checkbox"/>
		<br/>
		<div id="div_album_password" style="display:none">
			请输入6位密码：<input id="album_password" name="album.password" value="${album.password}" size="6" class="input"/>
		</div>
		<button class="btn1" type="button" name="submitAlbum" onclick="javascript:submitAlbumForm();">保存</button>
	</form>
</div>
<div class="pagediv martop10 tc clear">
</div>
<script>
$(document).ready(function(){
	var lockStatus = '<c:out value="${album.lockStatus}"/>';
	if(lockStatus == '<c:out value="${LOCK_STATUS}"/>'){
		$("#album_lockstatus").attr("checked", true);
		albumLockStatus($("#album_lockstatus"));
	}
});
function albumLockStatus(obj){
	if($(obj).attr("checked")==true){
		$("#div_album_password").css("display", "block");
	}else{
		$("#div_album_password").css("display", "none");
	}
}
function submitAlbumForm(){
	$.ajax({
		type : "POST",
		url : ctx + "/album/save.do",
		data : $("#f_new_album").serialize(),
		dataType:"xml", 
		timeout:20000,
		success : function(data){
			if($(data).find('result').text().toUpperCase().indexOf("TRUE") >= 0){
				spaceIndexNav('<c:out value="${SPACE_WIDGET_PART_ALBUM}"/>');
			}else{
				spaceIndexNav('<c:out value="${SPACE_WIDGET_PART_ALBUM}"/>');
			}
		},
		error: function(){
			spaceIndexNav('<c:out value="${SPACE_WIDGET_PART_ALBUM}"/>');
		}
	});
}
</script>